import React, { useRef, useState, useEffect } from 'react';
import { connect } from 'umi';
import TableDataBlock from '@/components/TableDataBlock';
import { reloadTab } from '@/utils/utils';
import { notification } from 'antd';
import { Button, Modal, Space, Form, Row, Col } from 'antd';
import {  } from '@/common/contact';
import FormCondition from '@/components/FormCondition';
import { AdminType } from '@/common/contact';
import { useUpdateEffect } from 'ahooks';
const AuthFormSetting = (props) => {
  const {
    visible = false,
    onClose,
    loading,
    organizationAuthAdminList,
  } = props;
  const { show = false, detail = {}, } = visible;
  const childRef = useRef();


  const searchItems = [
    {
      label: '员工姓名',
      name: 'keyword',
    },
    {
      label: '状态',
      name: 'status',
      type: 'select',
      select: {
        0: '禁用',
        1: '启用'
      },
    }
  ];

  const getColumns = [
    {
      title: '姓名',
      dataIndex: 'username',
    },
    {
      title: '岗位类型',
      dataIndex: 'adminType',
      render: (e) => {
        return AdminType[e];
      },
    },
  ];
  const modalProps = {
    title: `选择员工`,
    width: 900,
    visible: show,
    maskClosable: true,
    destroyOnClose: true,
    zIndex: 1001,
    confirmLoading: loading,
    footer: null
  };

  return (
    <Modal {...modalProps} onCancel={onClose}>
      <TableDataBlock
        params={{
          ...detail,
        }}
        searchItems={searchItems}
        cRef={childRef}
        loading={loading}
        columns={getColumns}
        rowKey={(record) => `${record.id}`}
        dispatchType="system/fetchSearchAdmin"
        {...organizationAuthAdminList}
      ></TableDataBlock>
    </Modal>
  );
};

export default connect(({ system, loading }) => ({
  ...system,
  loading: loading.models.system || loading.models.subscriber,
}))(AuthFormSetting);
